//
//  GRRiceOderDetailGoodCell.m
//  YC_GRice
//
//  Created by luojinrong11 on 2018/9/8.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRRiceOderDetailGoodCell.h"

@implementation GRRiceOderDetailGoodCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)updateWithModel:(id)model atIndexPath:(NSIndexPath *)indexPath inView:(UIView *)view{
    self.orderModel = model;
    self.nickNameLabel.text = self.orderModel.onePayName;
    self.titleLabel.text = self.orderModel.title;
 
    self.totalMoneyLabel.text =  [NSString stringWithFormat:@"%.2lf",self.orderModel.totalMoney];
    NSString * detailStr =  [NSString stringWithFormat:@"实付￥%.2lf 优惠￥%.2lf",self.orderModel.payMoney ,self.orderModel.costPoint];
    NSMutableAttributedString * attributeStr = [[NSMutableAttributedString alloc]initWithString:detailStr];
    NSRange rangeS =  [detailStr rangeOfString:@"实付" ];
    NSRange rangeF = [ detailStr rangeOfString:@"优惠" ];
    NSMutableAttributedString * attributingStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"￥%.2lf",self.orderModel.totalPrice] attributes:@{NSForegroundColorAttributeName:HEXCOLOR(0x999999),NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}];
    self.originalPriceLabel.attributedText = attributingStr ;
    self.priceLabel.text = [NSString stringWithFormat:@"￥%.2lf",self.orderModel.discountPrice];
    self.countLabel.text = [NSString stringWithFormat:@"x%ld",self.orderModel.number];
    [attributeStr setAttributes:@{NSForegroundColorAttributeName:HEXCOLOR(0xF11544),NSFontAttributeName:[UIFont boldSystemFontOfSize:23]} range:NSMakeRange(rangeS.location+rangeS.length, rangeF.location - rangeS.length)];
    self.priceDetailLabel.attributedText = attributeStr;
    self.discountLabel.text = [NSString stringWithFormat:@"-￥%.2lf",self.orderModel.costPoint];
    if ([self.orderModel.state isEqualToString:@"pay"]) {
        self.priceDetailLabel.hidden = YES;
    }else{
        self.priceDetailLabel.hidden = NO;
    }
    [self.goodImageView sd_setImageWithURL:[NSURL URLWithString:self.orderModel.mainPhoto] placeholderImage:[UIImage imageNamed:@""]];
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
